﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTime>
#include <QDebug>
#include <QDate>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QTime time1(23,59,59);
    qDebug()<<time1;
    QTime time2=QTime::currentTime();
    qDebug()<<time2;

    int h=time2.hour();
    int m=time2.minute();
    int s=time2.second();
    qDebug()<<h<<m<<s;
    time1=time2.addSecs(3600);
    qDebug()<<time1;
    qDebug()<<time1.secsTo(time2);

    QTime time3=QTime::fromString("12点24分30秒","hh点mm分ss秒");
    qDebug()<<time3;

    QDate date=QDate::currentDate();
    qDebug()<<date.dayOfYear();
    qDebug()<<date.weekNumber();
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_Current_clicked()
{
    ui->timeEdit_start->setTime(QTime::currentTime());
    ui->dateEdit_start->setDate(QDate::currentDate());
    ui->dateTimeEdit_start->setDateTime(QDateTime::currentDateTime());
}

void MainWindow::on_spinBox_hours_valueChanged(int arg1)
{
    QTime time=ui->timeEdit_start->time();
    time=time.addSecs(3600*arg1);
    ui->timeEdit_end->setTime(time);
}

void MainWindow::on_spinBox_day_valueChanged(int arg1)
{
    QDate date=ui->dateEdit_start->date();
    date=date.addDays(arg1);
    ui->dateEdit_end->setDate(date);
}

void MainWindow::on_spinBox_days_2_valueChanged(int arg1)
{
    QDateTime datetime=ui->dateTimeEdit_start->dateTime();
    datetime=datetime.addDays(arg1);
    ui->dateTimeEdit_end->setDateTime(datetime);
}
